package org.cnc.explain.lifecycle;

import org.cnc.explain.util.StepCount;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
import org.springframework.stereotype.Component;
import org.springframework.util.ReaderHelper;

/**
 * <p>
 * 
 * </p>
 *
 * @author zhiyong.tan
 * @since 2022-08-07
 */
@Component
public class LifeCycleDestructionAwareBeanPostProcessor  implements DestructionAwareBeanPostProcessor {
	@Override
	public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
		if(LifeCycleBean.BEAN_NAME.equals(beanName)){
			System.out.println("\n\n");
			ReaderHelper.beanLifecycleTrace ( StepCount.getStep() + "bean [%s] 销毁 DestructionAwareBeanPostProcessor前置操作" ,beanName);
			ReaderHelper.formatTrace();
			System.out.println("\n\n");
		}
	}
}
